﻿<!DOCTYPE>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=EDGE;IE=11;IE=8,chrome=1" />
    <title>热表设备能力平衡页面</title>
    <link href="/InSiteWebApplication/Content/Easyui/themes/metro/easyui.css" rel="stylesheet" />
    <link href="/InSiteWebApplication/Content/Easyui/custom-easyui.css" rel="stylesheet" />
    <link href="/InSiteWebApplication/Content/Easyui/themes/icon.css" rel="stylesheet" />
    <style type="text/css">
        .infoPanel
        {
            border: 1px solid Black;
            border-radius: 10px;
            float: left;
            font-size: 16px;
            font-weight: bold;
            width: 150px;
            padding: 10px;
            background-color: #F0FFFF;
            text-align: center;
            justify-content: center; /* 水平居中 */
            align-items: center; /* 垂直居中 */
        }
        .iconInfo
        {
            height: 30px;
            width: 30px;
            float: left;
            background-position: center;
            background-repeat: no-repeat;
            background-size: cover;
            display: block;
            text-align: center;
        }
    </style>
</head>
<body>
    <div id="mainSec" style="margin: 0px 1px 0px 0px">
        <div class="panelSection">
            <div class="easyui-panel " title="查询区域" style="padding: 3px; width: 100%" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false">
                <form id="queryForm" action="">
                <div style="margin: 3px 0px 3px 3px">
                    <div style="float: left;">
                        <div class="divLabel" style="margin-bottom: 5px">
                            工区：</div>
                        <select style='width: 120px; height: 20px' id='ddlWorkCenter' name="WorkCenterId"
                            data-options='editable:false,panelHeight:100' class='easyui-combobox'>
                        </select>
                    </div>
                    <div style="float: left; margin-left: 10px">
                        <div class="divLabel" style="margin-bottom: 5px">
                            班组：</div>
                        <select style='width: 120px; height: 20px' id='ddlTeam' name="TeamId" data-options='editable:false,panelHeight:100'
                            class='easyui-combobox'>
                        </select>
                    </div>
                    <div style="float: left; margin-left: 10px">
                        <div class="divLabel" style="margin-bottom: 5px">
                            设备：</div>
                        <input id="txtResourceName" name="ResourceName" class="easyui-textbox" style="width: 120px;
                            height: 20px" />
                    </div>
                    <div style="float: left; margin-left: 10px">
                        <div class="divLabel" style="margin-bottom: 5px">
                            订单号：</div>
                        <input id="txtMfgOrderName" name="MfgOrderName" class="easyui-textbox" style="width: 120px;
                            height: 20px" />
                    </div>
                    <div style="float: left; margin-left: 10px">
                        <div class="divLabel" style="margin-bottom: 5px">
                            件号：</div>
                        <input id="txtProductName" name="ProductName" class="easyui-textbox" style="width: 120px;
                            height: 20px" />
                    </div>
                    <div style="float: left; margin-left: 10px">
                        <div class="divLabel" style="margin-bottom: 5px">
                            批次号：</div>
                        <input id="txtContainerName" name="ContainerName" class="easyui-textbox" style="width: 120px;
                            height: 20px" />
                    </div>
                    <div style="float: left; margin-left: 10px">
                        <div class="divLabel" style="margin-bottom: 5px">
                            排产开始时间：</div>
                        <input id="txtPlanStartTime1" name="PlanStartTime1" class="easyui-datebox" style="width: 120px;
                            height: 20px" data-options="editable:false" />
                        -
                        <input id="txtPlanStartTime2" name="PlanStartTime2" class="easyui-datebox" style="width: 120px;
                            height: 20px" data-options="editable:false" />
                    </div>
                    <div style="float: left; margin-left: 10px">
                        <div class="divLabel" style="margin-bottom: 5px">
                            排产结束时间：</div>
                        <input id="txtPlanEndTime1" name="PlanEndTime1" class="easyui-datebox" style="width: 120px;
                            height: 20px" data-options="editable:false" />
                        -
                        <input id="txtPlanEndTime2" name="PlanEndTime2" class="easyui-datebox" style="width: 120px;
                            height: 20px" data-options="editable:false" />
                    </div>
                    <div style="float: left; margin-left: 10px">
                        <button id="btnSearch" class="easyui-linkbutton" type="button" data-options="" style="margin-top: 16px;
                            width: 80px;">
                            查询</button>
                        <button id="btnReset" class="easyui-linkbutton" type="button" data-options="" style="margin-top: 16px;
                            width: 50px;">
                            重置</button>
                    </div>
                    <div style="clear: both">
                    </div>
                </div>
                </form>
            </div>
        </div>
        <div class="panelSection">
            <div class="easyui-panel" title="设备预览" style="padding: 3px; width: 100%;" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false">
                <div class="infoPanel">
                    <i class="iconInfo" style="background-image: url(../../../Content/icons/三角形.png);">
                    </i>
                    <div style="float: left; margin-left: 5px">
                        <div>
                            设备总数</div>
                        <div id="resCount" style="">
                            </div>
                    </div>
                </div>
                <div class="infoPanel" style="margin-left: 20px">
                    <i class="iconInfo" style="background-image: url(../../../Content/icons/记事本.png);">
                    </i>
                    <div style="float: left; margin-left: 5px">
                        <div>
                            任务总数</div>
                        <div id="taskCount" style="">
                            </div>
                    </div>
                </div>
                <div class="infoPanel" style="margin-left: 20px">
                    <i class="iconInfo" style="background-image: url(../../../Content/icons/电波心电图.png);">
                    </i>
                    <div style="float: left; margin-left: 5px">
                        <div>
                            平均负荷</div>
                        <div id="averLoad" style="">
                            </div>
                    </div>
                </div>
                <div class="infoPanel" style="margin-left: 20px">
                    <i class="iconInfo" style="background-image: url(../../../Content/icons/消息异常.png);">
                    </i>
                    <div style="float: left; margin-left: 5px">
                        <div>
                            异常</div>
                        <div id="errorCount" style="">
                            </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="panelSection">
            <div class="easyui-panel " title="设备负荷信息" style="padding: 3px; width: 100%" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false">
                <div id="dvApsPlanInfo" class="dvgrid-cellwarp" style="background: #fff; margin: 3px 0px 3px 3px">
                    <div style="width: 99%">
                        <table id="gdResourceInfo" class="easyui-datagrid" style="width: 100%; height: 500px;"
                            data-options="fitColumns:true,rownumbers:true">
                        </table>
                    </div>
                    <div style="clear: both">
                    </div>
                </div>
            </div>
        </div>
        <div class="panelSection">
            <div class="easyui-panel " title="设备任务" style="padding: 3px; width: 100%" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false">
                <div id="Div4" class="dvgrid-cellwarp" style="background: #fff; margin: 3px 0px 3px 3px">
                    <div style="width: 99%">
                        <table id="gdApsStepInfo" class="easyui-datagrid" style="width: 100%; height: 500px;"
                            data-options="fitColumns:true,rownumbers:true">
                        </table>
                    </div>
                    <div style="clear: both">
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
<script src="/InSiteWebApplication/Scripts/CustomPageJs/ReferenceJsLib.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.easyui.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/datagrid-detailview.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/easyui-lang-zh_CN.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Scripts/CustomPageJs/CustomCommon.js" type="text/javascript"></script>
<script type="text/javascript">
    /*
    创建人：zhangrj
    日期：2024-09-20
    描述：热表设备能力平衡页面JS
    */
    var page = {
        rootPath: getRootPath(), //网站根路径
        url: getRootPath() + "/Ashx/ApsHandler/RbApsResourceBalanceHandler.ashx",
        commonUrl: getRootPath() + "/Ashx/CommonHandler.ashx",
        //初始化页面
        init: function () {
            page.bind();
            page.initPageData();
        },
        //页面事件绑定
        bind: function () {
            $("#gdApsStepInfo").datagrid({
                columns: [[
                { field: 'CONTAINERNAME', title: '批次名', width: 200 },
                { field: 'STEPNO', title: '工步号', width: 100 },
                { field: 'STEPDESC', title: '工步名称', width: 150 },
                { field: 'STARTTIME', title: '排产开始时间', width: 150 },
                { field: 'ENDTIME', title: '排产结束时间', width: 150 }
                ]]
            }); //绑定数据和列
            //查询按钮
            $('#btnSearch').on("click", function () {
                page.clearPage(false, true);
                page.searchData();
            });
            //清除按钮
            $('#btnReset').on("click", function () {
                page.clearPage(true, true);
            });
        },
        //初始化页面数据
        initPageData: function () {
            //绑定查询的工区
            $('#ddlWorkCenter').combobox({
                url: page.commonUrl + "?action=getWorkcenterByFactory",
                valueField: 'WORKCENTERID',
                textField: 'WORKCENTERNAME',
                onSelect: function (rec) {
                    page.bindTeamData(rec.WORKCENTERID);
                }
            });
        },
        //绑定班组（查询）
        bindTeamData: function (workcenterID) {
            page.post(page.commonUrl, { action: "GetTeam", workCenterId: workcenterID }, true, function (res) {
                if (!res.Result) {
                    displayMessage(res.Message, res.Result);
                    return;
                }
                $('#ddlTeam').combobox({
                    valueField: 'TEAMID',
                    textField: 'TEAMNAME',
                    data: res.DBTable
                });
            });
        },
        //查询
        searchData: function () {
            var params = {};
            var queryFormData = $("#queryForm").serializeArray();
            $.each(queryFormData, function () {
                params[this.name] = this.value;
            });
            var colParams = [
                { field: 'RESOURCENAME', title: '设备编号', width: 150 },
                { field: 'RESOURCEDESC', title: '设备名称', width: 200 },
                { field: 'WORKCENTERNAME', title: '工区', width: 150 },
                { field: 'TEAMNAME', title: '班组', width: 150 },
                { field: 'RESSTATUS', title: '状态', width: 120 }
            ];
            page.post(page.url, { action: "GetApsResourceWeekData", params: JSON.stringify(params) }, true, function (res) {
                if (!res.Result) {
                    displayMessage(res.Message, res.Result);
                    return;
                }
                colParams = $.merge(colParams, res.ReturnData.colParams) //合并列名
                $("#gdResourceInfo").datagrid({ columns: [colParams], data: res.DBTable }); //绑定数据和列
                $("#gdResourceInfo").datagrid("reload"); //重新加载
                $("#resCount").text(res.RowCount); //设备数量
                $("#taskCount").text(res.ReturnData.totalTaskCount);//任务数
                $("#averLoad").text(res.ReturnData.averLoad);//平均负荷
                $("#errorCount").text(res.ReturnData.totalTaskCount);//设备异常数量
            });
        },
        //绑定设备下的任务信息
        bindResApsData: function () {
            var selectRows = $("#gdApsPlanInfo").datagrid('getChecked');
            if (selectRows.length === 0) {
                displayMessage("请选择批次", false);
                return;
            }
            var datas = selectRows.map(function (item) {
                return {
                    containerId: item.CONTAINERID,
                    containerName: item.CONTAINERNAME,
                    qty: item.QTY
                }
            });
            page.post(page.url, { action: "SaveApsPlanSendToDis", params: JSON.stringify(datas) }, true, function (res) {
                if (res.Result) {
                    page.searchData();
                }
                displayMessage(res.Message, res.Result);
            });
        },
        //禁用页面按钮
        disableBtn: function () {
            $("#mainSec").find(".easyui-linkbutton").each(function () {
                $(this).linkbutton('disable');
            });
        },
        //启用页面按钮
        enableBtn: function () {
            $("#mainSec").find(".easyui-linkbutton").each(function () {
                $(this).linkbutton('enable');
            });
        },
        //清除页面（查询区域，列表区域）
        clearPage: function (query, list) {
            if (query) {
                $("#ddlWorkCenter").combobox("clear"); //工区
                $("#ddlTeam").combo("clear"); //班组
                $("#ddlTeam").combo("panel").empty();
                $("#txtMfgOrderName").textbox("clear"); //订单
                $("#txtResourceName").textbox("clear"); //设备
                $("#txtContainerName").textbox("clear"); //批次号
                $("#txtProductName").textbox("clear"); //件号
                $("#txtPlanStartTime1").datebox("clear"); //排产开始时间
                $("#txtPlanStartTime2").datebox("clear"); //排产开始时间
                $("#txtPlanEndTime1").datebox("clear"); //排产结束时间
                $("#txtPlanEndTime2").datebox("clear"); //排产结束时间
            }
            if (list) {
                clearEasyuiDataGrid("gdResourceInfo"); //清空列表
                clearEasyuiDataGrid("gdApsStepInfo"); //清空列表
            }
        },
        //post数据（路径，参数，是否异步，成功返回方法）
        post: function (url, param, async, callback) {
            $.ajax({
                type: "Post",
                url: url,
                data: param,
                cashe: false,
                async: async,
                dataType: "json",
                beforeSend: function () {
                    $.messager.progress({ text: '', msg: '处理中...' });
                },
                success: function (data) {
                    $.messager.progress('close');
                    callback(data);
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    $.messager.progress('close');
                    displayMessage(XMLHttpRequest.responseText, false);
                    $("body").find(".easyui-linkbutton").each(function () {
                        $(this).linkbutton('enable');
                    });
                }
            });
        }
    };
    $(function () {
        page.init();
    });
</script>
